package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"time"
)

func helloHandler(rw http.ResponseWriter, r *http.Request) {
	var data []byte
	for i := 0; i < 10000; i++ {
		data = append(data, 'h')
	}
	if _, err := rw.Write(data); err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(r)
}
func fuckHandler(rw http.ResponseWriter, r *http.Request) {
	defer r.Body.Close()
	rw.Write([]byte(r.RequestURI))
	fmt.Println(r.Body)
	fmt.Println(r.RequestURI)
	fmt.Println(r.Host)
	fmt.Println(r.Response)
	fmt.Println(r.Form)
	fmt.Printf("%v\n", r)
}
func fuckHandler2(rw http.ResponseWriter, r *http.Request) {
	defer r.Body.Close()
	//	r.ParseForm()
	//	rw.Write([]byte(r.RequestURI))
	//	rw.Write([]byte("haha"))
	//	var data []byte
	//	_, _ = r.Body.Read(data)
	//	fmt.Println(r.Body)
	//	fmt.Println(data)
	//	fmt.Println(r.RequestURI)
	//	fmt.Println(r.Host)
	//	fmt.Println(r.PostForm)
	body, err := ioutil.ReadAll(r.Body)
	fmt.Printf("%s", "%v", string(body), err)
}
func main() {
	s := &http.Server{
		Addr:              ":8888",
		ReadTimeout:       1 * time.Millisecond,
		WriteTimeout:      1 * time.Millisecond,
		ReadHeaderTimeout: 1 * time.Millisecond,
	}
	http.HandleFunc("/fuckpost", fuckHandler2)
	http.HandleFunc("/fuckget", fuckHandler)
	http.HandleFunc("/", helloHandler)
	log.Fatal(s.ListenAndServe())
}
